﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
/*
Copyright 2010 Mirosław M. Mączka

This file is part of Flac2Wma.

    Flac2Wma is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
namespace Flac2Wma
{
    public class CleanTreeView
    {

        public static void WalkTree(TreeNodeCollection tnRoot)
        {
            // Now find all the subdirectories under this directory.
            for (int n = tnRoot.Count-1; n >=0 ; n--)
            {
                //string a = tnRoot[n].Text;
                WalkTree(tnRoot[n].Nodes);
                if (0 == tnRoot[n].GetNodeCount(false))
                {
                    if ((!tnRoot[n].Checked) && (tnRoot[n].Parent != null))
                    {
                        tnRoot.RemoveAt(n);
                        continue;
                    }
                }
            }
            return ;
        }
        //
        //
        //
        //
    }//class
}//namespace
